package cn.wolfcode.config;

import cn.wolfcode.interceptor.LoginInterceptor;
import cn.wolfcode.interceptor.PermissionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.awt.event.PaintEvent;

//声明是一个配置类 配置拦截
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    public static final String[] excludePathPatterns = {
            "/login.html",
            "/userLogin",
            "/index",
            "/messageBoard/list",
            "/messageBoard/reply",
            "/systemDictionaryItem/selectByTypeSn",
            "/systemDictionaryItem/selectByParentId",
            "/messageBoard/save",
            "/appointment/save",
            "/css/**",
            "/js/**",
            "/img/**"
    };

    //获取拦截器对象
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Autowired
    private PermissionInterceptor permissionInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns(excludePathPatterns);
            registry.addInterceptor(permissionInterceptor).addPathPatterns("/**").excludePathPatterns(excludePathPatterns);
    }
}
